/*
 * @Author: YYJ
 * @Date: 2023-12-16 14:40:39
 * @Description: 
 * @FilePath: \lgd-admin\src\services\person\account\index.tsx
 */
import { request } from '@umijs/max';

export interface AccountParams {
  accountType?: string;
}

export interface AccountDetailParams {
  accountId: number;
}

export interface PersonAccountItem {
  id: number;
  accountType: string;
  accountName?: string;
  inAmount: number;
  outAmount: number;
  balance: number;
  billAmount: number;
  creditDay?: string;
  dueDay?: string;
  graceDays?: number;
  sortNum?: number;
  updateTime?: Date;
}

export interface AccountOpItem {
  id?: number;
  accountType: string;
  accountName?: string;
  inAmount?: number;
  outAmount?: number;
  balance?: number;
  billAmount?: number;
  opAmount?: number;
  interests?: number;
  remark?: string;
  opType: 'transIn' | 'transOut' | 'lendTo'| 'lendBack' | 'consume' | 'refund' | 'check' | 'loanIn' | 'loanBack' | 'borrowIn' | 'borrowBack';
}

export async function queryList(params?: AccountParams) {
  return request<API.LgdTable>('/admin/personAccount/queryList', {
    params,
  });
}

export async function queryDetailList(params?: AccountDetailParams) {
  return request<API.LgdTable>('/admin/personAccount/queryDetailList', {
    params,
  });
}

export async function add(body: PersonAccountItem) {
  return request<API.LgdResult>('/admin/personAccount/add', {
    method: 'POST',
    data: body
  });
}

export async function update(body: AccountOpItem) {
  return request<API.LgdResult>('/admin/personAccount/update', {
    method: 'POST',
    data: body
  });
}

export async function remove(id?: number) {
  return request('/admin/personAccountItem/remove?id=' + id, {
    method: 'POST',
  });
}
